﻿<UserControl x:Class="NthDownload.DownloadPlugins.Http.Views.HttpCredentialsDetailsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:behaviors="clr-namespace:NthDownload.Common.Interactivity.Behaviors;assembly=NthDownload.Common"
             xmlns:validationrules="clr-namespace:NthDownload.Common.Validation.Rules;assembly=NthDownload.Common"
             HorizontalAlignment="Center">
    <Grid>
        <Grid.BindingGroup>
            <BindingGroup NotifyOnValidationError="True" Name="bg">
                <i:Interaction.Behaviors>
                    <behaviors:BindingGroupValidatorBinder BindingGroupValidator="{Binding BindingGroupValidator}" />
                </i:Interaction.Behaviors>
            </BindingGroup>
        </Grid.BindingGroup>        
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Text="Domain" Style="{StaticResource Label}" Margin="0,0,5,0"/>
        <TextBox Grid.Row="0" Grid.Column="1" Style="{StaticResource MediumTextBox}">
            <i:Interaction.Behaviors>
                <behaviors:FocusOnLoad />
            </i:Interaction.Behaviors>
            <TextBox.Text>
                <Binding Path="Credentials.Domain" BindingGroupName="bg">
                    <Binding.ValidationRules>
                        <validationrules:RequiredValidationRule />
                        <validationrules:UriValidationRule SupportedSchemas="http,https" />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
        </TextBox>

        <TextBlock Grid.Row="1" Text="Username" Style="{StaticResource Label}" Margin="0,5,5,0"/>
        <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Credentials.Username, BindingGroupName=bg}" Style="{StaticResource MediumTextBox}" Margin="0,5,0,0" />

        <TextBlock Grid.Row="2" Text="Password" Style="{StaticResource Label}" Margin="0,5,5,0"/>
        <PasswordBox Grid.Row="2" Grid.Column="1" Style="{StaticResource MediumPasswordBox}" Margin="0,5,0,0">
            <i:Interaction.Behaviors>
                <behaviors:PasswordBoxBinder Password="{Binding Credentials.Password, Mode=TwoWay, BindingGroupName=bg}" />
            </i:Interaction.Behaviors>
        </PasswordBox>

        <StackPanel Grid.Row="3" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,5,0,0">
            <Button x:Name="Save" Content="Save" Margin="5,0,0,0" />
            <Button x:Name="Cancel" Content="Cancel" Margin="5,0,0,0" />
        </StackPanel>
    </Grid>
</UserControl>
